package cn.edu.sasu.adapter.newsdetail.newsmore;

import cn.edu.sasu.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 加载更多新闻的ListView的Adapter
 * 
 * @author yubaolinfish
 * 
 */
public class NewsMoreAdapter extends BaseAdapter {
	private String[] array = null;
	private Context context = null;

	public NewsMoreAdapter(String[] array, Context context) {
		this.array = array;
		this.context = context;
	}

	@Override
	public int getCount() {
		return array.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Tv tv = null;
		if (convertView == null) {

			convertView = ((LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(R.layout.news_more_item, null);

			tv = new Tv();
			tv.name = (TextView) convertView
					.findViewById(R.id.tv_news_more_item);
			convertView.setTag(tv);
		} else {
			tv = (Tv) convertView.getTag();
		}
		tv.name.setText(array[position]);
		return convertView;
	}

	/**
	 * 表示新闻的条目的内部类
	 * 
	 * @author yubaolinfish
	 * 
	 */
	private static class Tv {
		/**
		 * 表示新闻的条目名称
		 */
		public TextView name;
	}
}